#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/08/19
# @Author   :Changshu
# @File     :practice_83.py

# 83. 删除排序链表中的重复元素

class ListNode():
	def __init__(self,x):
		self.val=x
		self.next=None


def deleteDuplicates(head: ListNode) -> ListNode:
	if head==None:
		return None
	p=head
	q=p.next
	while q!=None:
		if p.val==q.val:
			p.next=q.next
		else:
			p=p.next
		q=p.next
	return head

def printListNode(head:ListNode):
	p=head
	while p!=None:
		print(p.val,end=' ')
		p=p.next

if __name__ == '__main__':
	head = ListNode(1)

	p1=ListNode(1)
	head.next=p1

	p2=ListNode(2)
	p1.next=p2

	p3=ListNode(3)
	p2.next=p3

	p4=ListNode(3)
	p3.next=p4


	deleteDuplicates(head)
	printListNode(head)

